package Book;

public class book {
    private String name;//书名
    private String author;//作者
    private String type;//类型
    private int price;//价格
    private boolean IfBorrowed;//是否被借阅，默认为false

    //构造方法
    public book(String name, String author, String type, int price) {
        this.name = name;
        this.author = author;
        this.type = type;
        this.price = price;
    }

    //private访问限制需要用Set和Get方法引用读写
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public boolean getisIfBorrowed() {
        return IfBorrowed;
    }

    public void setIfBorrowed(boolean ifBorrowed) {
        IfBorrowed = ifBorrowed;
    }

    //重写toString方法，不重写只会打印哈希值

    @Override
    public String toString() {
        return "图书{" +
                "书名='" + name + '\'' +
                ", 作者='" + author + '\'' +
                ", 类型='" + type + '\'' +
                ", 价格=" + price +((IfBorrowed == true) ? "，已被借阅" : "，未被借阅")
                 +'}';
    }
}
